//
//  BySuperLottoHeadView.m
//  caipiao_ios
//
//  Created by mc on 2018/7/12.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "BySuperLottoHeadView.h"

@implementation BySuperLottoHeadView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = BY_BACKGROUND_COLOR;
        UIView *backgroundView = [[UIView alloc] init];
        [self addSubview:backgroundView];
        [backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(5);
            make.right.equalTo(self).offset(-5);
            make.top.equalTo(self).offset(10);
            make.bottom.equalTo(self).offset(-10);
        }];
        backgroundView.layer.cornerRadius = 5;
        backgroundView.layer.masksToBounds = YES;
        backgroundView.backgroundColor = [UIColor whiteColor];
        
        UILabel *topLabel = [[UILabel alloc] init];
        [backgroundView addSubview:topLabel];
        [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(backgroundView).offset(10);
            make.left.equalTo(backgroundView).offset(10);
            make.right.equalTo(backgroundView).offset(-10);
            make.height.mas_equalTo(@20);
        }];
        topLabel.textColor = [UIColor blackColor];
        topLabel.font = FONT(13);
        topLabel.numberOfLines = 0;
        topLabel.text = @"";
        
        ByDottedLineView *line = [[ByDottedLineView alloc] init];
        line.direction = DottedLineViewDirectionHorizontalFromRight;
        line.lineColor = BY_LINE_COLOR;
        line.lengthPattern = @[@4, @3];
        [backgroundView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(backgroundView).offset(0);
            make.right.equalTo(backgroundView).offset(0);
            make.centerY.equalTo(backgroundView).offset(0);
            make.height.mas_equalTo(@1);
        }];
        
        
        UILabel *bottomLabel = [[UILabel alloc] init];
        [backgroundView addSubview:bottomLabel];
        
        bottomLabel.textColor = [UIColor grayColor];
        bottomLabel.font = FONT(13);
        bottomLabel.numberOfLines = 0;
        bottomLabel.text = @"";
        
        self.topLabel = topLabel;
        self.bottomLabel = bottomLabel;
        
        
        BySuperLottoCirclesView *circlesView = [[BySuperLottoCirclesView alloc] init];
        [backgroundView addSubview:circlesView];
        self.circlesView = circlesView;
        self.backgroundView = backgroundView;
        
    }
    return self;
}

- (void)setNetModel:(ByNetModel *)netModel{
    _netModel = netModel;
    
   NSString *str =  [NSString stringWithFormat:@"第%@期",netModel.number];
    CGFloat width = [str getRectOfStringWithSize:CGSizeMake(100, 20) font:13].size.width + 5;
    [self.bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.backgroundView).offset(-10);
        make.left.equalTo(self.backgroundView).offset(10);
        make.height.mas_equalTo(@20);
        make.width.mas_equalTo(@(width));
    }];
    
    [self.circlesView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomLabel.mas_right).offset(10);
        make.right.equalTo(self.backgroundView).offset(-10);
        make.centerY.equalTo(self.bottomLabel).offset(0);
        make.height.mas_equalTo(@40);
    }];
}


@end
